package com.vertxsample.samples.testconsulclient.controller

import com.vertxsample.samples.core.web.BaseController
import com.vertxsample.samples.core.web.RequestContext
import com.vertxsample.samples.testconsulclient.dao.SqlDAO
import io.vertx.core.json.Json
import java.util.concurrent.CompletableFuture

class JsonController(requestContext: RequestContext) : BaseController(requestContext) {


    fun toJson(): CompletableFuture<String> {
          val sqlDAO = SqlDAO(requestContext.dslContext);

          return sqlDAO.getStaff(requestContext.routingContext.queryParam("staffid")[0]).thenApply({result->Json.encode(result)})
    }
}